import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.qf.service.DocService;
import com.qf.service.IndexService;
import com.qf.service.impl.DocServiceImpl;
import com.qf.service.impl.IndexServiceImpl;
import org.junit.Test;

import java.io.IOException;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/*
杨威
2022/1/17
21:29
*/
public class test1 {
    ObjectMapper objectMapper=new ObjectMapper();

    @Test
    public void test1() throws IOException {
        IndexService indexService=new IndexServiceImpl();
        indexService.createIndex("index40");
    }
    @Test
    public void test2() throws Exception {
        DocService docService=new DocServiceImpl();
        Map map = new HashMap<>();
        map.put("name", "低价奥特曼");
        map.put("author", "全庸");
        map.put("count", 1000);
        map.put("on-sale", new Date());
        String json = objectMapper.writeValueAsString(map);
        docService.addDoc("index40",json);

    }

    @Test
    public void test3() throws Exception {
        DocService docService=new DocServiceImpl();
        Map map = new HashMap<>();
        map.put("name", "低价奥特曼2");
        map.put("author", "全庸2");
        map.put("count", 1000);
        map.put("on-sale", new Date());
        String json = objectMapper.writeValueAsString(map);
        docService.addDocWithId("index40","102",json);

    }

    @Test
    public void test4() throws Exception {
        DocService docService=new DocServiceImpl();
        Map map = new HashMap<>();
        map.put("name", "hello es");
        map.put("author", "大海2");
        map.put("count", 1000);
        map.put("on-sale", new Date());
        String json = objectMapper.writeValueAsString(map);
        docService.updateDoc("index40","101",json);
    }

    @Test
    public void test() throws Exception {
        DocService docService=new DocServiceImpl();

        docService.deleteDoc("index40","101");
    }

}
